package com.ichengzi.audit.human.repository.es.controller;

import com.ichengzi.audit.human.repository.es.service.ElasticSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * es web
 *
 * @author zmz
 * @since 2023-10-13
 */

@RestController
public class ElasticsearchController {
    @Autowired
    private ElasticSearchService elasticsearchService;

    @GetMapping(value = "/existsIndex/{indexName}")
    public boolean existsIndex(@PathVariable String indexName){
        return elasticsearchService.existsIndex(indexName);
    }

    @GetMapping(value = "/createIndex/{indexName}")
    public boolean createIndex(@PathVariable String indexName){
        return elasticsearchService.createIndex(indexName);
    }

    @GetMapping(value = "/deleteIndex/{indexName}")
    public boolean deleteIndex(@PathVariable String indexName){
        elasticsearchService.deleteIndex(indexName);
        return elasticsearchService.existsIndex(indexName);
    }

}
